package com.weic.controller;

import com.weic.pojo.User;
import org.junit.Before;
import org.junit.Test;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

@RestController
public class ThirdController {

    private SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");

    @RequestMapping(value = "/getParam.do")
    public String getParam(String id, @RequestParam("pwd") String password){
        return "id:"+id+" pwd:"+password;
    }


    @RequestMapping(value = "/getParamByPojo.do")
    public String getParamByPojo(HttpServletRequest request, HttpServletResponse response){
        String pname = request.getParameter("pname");
        System.out.println(pname);
        return pname;
    }




    @Before
    public void before(){
        simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
    }
    @Test
    public void testDateStr(){
        String string = "1952-06-07";
        Date date = null;
        try {
            date = simpleDateFormat.parse(string);
        } catch (ParseException e) {
            e.printStackTrace();
        }
        System.out.println(date);


    }
}
